# Contributor: Alex Yam <alex@alexyam.com>
# Maintainer: Alex Yam <alex@alexyam.com>
pkgname=fig2dev
pkgver=3.2.8b
pkgrel=0
pkgdesc="translates Fig code to other graphic description languages"
url="https://sourceforge.net/projects/mcj/"
arch="all"
license="MIT"
makedepends="
	diffutils
	ghostscript
	gzip
	imagemagick
	libpng-dev
	netpbm
	"
subpackages="$pkgname-doc"
source="https://downloads.sourceforge.net/mcj/fig2dev-$pkgver.tar.xz"

# secfixes:
#   3.2.8b-r0:
#     - CVE-2021-37529
#     - CVE-2021-37530

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--enable-transfig
	make
}

check() {
	# Expected result:
	# 75 tests were successful.
	# 4 tests were skipped.
	#
	# Skipped tests:
 	# [5: $i18ndir/cs_CZ.ps must exist]
	# Broken test, only runs with "make installcheck", which then breaks:
	# ".../tests/testsuite.dir/at-groups/5/test-source: line 15:"
	# "/home/builder/aports/testing/fig2dev/src/fig2dev-3.2.8/fig2dev/tests/test1: not found"
	#
	# [55: accept large coordinates]
	# Broken test, stalls waiting for input after error:
	# "LaTeX Error: File 'pict2e.sty' not found."
	# "Type X to quit or <RETURN> to proceed,"
	# "or enter new name. (Default extension: sty)"
	# Fix: Removed "texlive" from makedepends to skip test
	#
	# [59: conditionally allocate \XFigu]
	# Passes with "texlive" in makedepends (but removed to skip test 55)
	#
	# [61: accept large coordinates]
	# Passes with "texlive" in makedepends (but removed to skip test 55)
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
b1f083db6c38d84e1df82c430fabda5ad13413e4d42eb20b6fd06fae5626911413c93846b7935873687b82f601e0674c3f3e1d36441dcfa1da6626bafc9d2139  fig2dev-3.2.8b.tar.xz
"
